package nix.demo7.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import nix.demo7.service.BookService;
import nix.servlet.BaseServlet;

public class BookServlet extends BaseServlet {

	private BookService bookService = new BookService();
	
	public String findAll(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setAttribute("list", bookService.findAll());
		return "f:/demo7/show.jsp";
	}

	public String findByCategory(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		int category = Integer.parseInt(request.getParameter("category"));
		request.setAttribute("list", bookService.findByCategory(category));
		return "f:/demo7/show.jsp";
	}
}
